<template>
  <div class="sidemenu has-header">
    <ul class="menu">
      <li class="menu-item" v-for="menu in menus" v-bind:key='menu.order'>
        <a @click="showShotcut(menu.type)">
          <i class="icon" :class="menu.icon"></i>
          <p>{{menu.name}}</p>
        </a>
      </li>
    </ul>
    <div class="sub-container" :style="hide?'left:0':''">
      <component :is="shotCut" @paint="doPaint"></component>
    </div>
  </div>
</template>

<script>
export default {
  props: ['menus', 'hide'],
  data () {
    return {
      shotCut: 'v-label-shotcut'
    }
  },
  methods: {
    doPaint: function (i) {
      this.$emit('paint', i)
    },
    showShotcut (type) {
      this.shotCut = `v-${type}-shotcut`
    }
  }
}
</script>

<style lang='scss'>
$menuWidth:60px;
@import '../config/variables.scss';
.sidemenu {
  &.has-header .menu,
  &.has-header .sub-container {
    top: 45px;
  }
  .menu {
    background: #3a4042;
    position: absolute;
    top: 0px;
    bottom: 0px;
    z-index: 5;
    width: $side-menu-width;
    padding: 0;
    list-style: none;
    text-align: center;
    line-height: 0;
    a:hover,
    a.actived {
      background: #5E6163;
    }
    a {
      color: #fbfdff;
      padding: 10px 0;
      display: inline-block;
      &:hover {
        color: #8affea;
      }
    }
    i {
      width: $side-menu-width;
      font-size: 20px;
    }
    p {
      margin: 0;
      font-size: 12px;
      line-height: 1.5;
    }
  }
  .sub-container {
    position: absolute;
    width: $sub-container-width;
    transition: left 1s;
    left: 60px;
    top: 0;
    bottom: 0;
    background: $sub-container-bg-color;
    overflow: scroll;
  }
}
</style>
